﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace abhishek.somnath.bidyut.library
{
    public class PrimeNo
    {
        public static bool IsPrime(int n)
        {
            bool flag = true;
            int r = n % 2;
            if (r == 0)
            {
                flag = false;
                return flag;
            }

            int sqrt = (int)Math.Sqrt(n);
            for (int i = 3; i <= sqrt; i += 2)
            {
                r = n % i;
                if (r == 0)
                {
                    flag = false;
                    break;
                }
            }
            return flag;
        }
    }
}
